/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.crm.sopm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import merlion.common.entity.DocFile;
import merlion.common.entity.Staff;
import merlion.crm.slcm.entity.SalesLead;

/**
 *
 * @author Yuwei nd Hong
 */
@Entity
public class SalesInquiry implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @ManyToOne(targetEntity=SalesLead.class, cascade={CascadeType.PERSIST,CascadeType.MERGE}, fetch=FetchType.EAGER) 
    private SalesLead salesLead;
    private Timestamp inquiryDate;
    private String siNumber;
    private String rfiNumber;
    private String dateStr;
    private String comments;
    private Boolean currency;
    private Double subtotal;
    private Double total;
    private Double orderDiscount;
    private Double memberDiscount;
    @OneToOne(targetEntity=DocFile.class, cascade={CascadeType.ALL}, fetch = FetchType.EAGER)
    private DocFile reqForInquiry;
    @OneToMany(targetEntity=ItemLine.class, cascade={CascadeType.PERSIST,CascadeType.MERGE}, fetch=FetchType.EAGER)
    private Collection<ItemLine> orderItems = new ArrayList<ItemLine>();
    @ManyToOne(targetEntity=Staff.class, cascade={CascadeType.PERSIST,CascadeType.MERGE}, fetch=FetchType.EAGER)
    private Staff customerExecutive;
    
    public SalesInquiry() {
        salesLead = new SalesLead();
        inquiryDate = new Timestamp(System.currentTimeMillis());
        dateStr = inquiryDate.toString();
        total=0.0;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public Staff getCustomerExecutive() {
        return customerExecutive;
    }

    public void setCustomerExecutive(Staff customerExecutive) {
        this.customerExecutive = customerExecutive;
    }

    public Timestamp getInquiryDate() {
        return inquiryDate;
    }

    public void setInquiryDate(Timestamp inquiryDate) {
        this.inquiryDate = inquiryDate;
    }

    public Collection<ItemLine> getOrderItems() {
        return orderItems;
    }

    public void setOrderItems(Collection<ItemLine> orderItems) {
        this.orderItems = orderItems;
    }

    public SalesLead getSalesLead() {
        return salesLead;
    }

    public void setSalesLead(SalesLead salesLead) {
        this.salesLead = salesLead;
    }

    public String getDateStr() {
        return dateStr;
    }

    public void setDateStr(String dateStr) {
        this.dateStr = dateStr;
    }
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }
    

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof SalesInquiry)) {
            return false;
        }
        SalesInquiry other = (SalesInquiry) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.crm.sopm.entity.SalesInquiry[ id=" + id + " ]";
    }

    /**
     * @return the rfiNumber
     */
    public String getRfiNumber() {
        return rfiNumber;
    }

    /**
     * @param rfiNumber the rfiNumber to set
     */
    public void setRfiNumber(String rfiNumber) {
        this.rfiNumber = rfiNumber;
    }

    /**
     * @return the currency
     */
    public Boolean getCurrency() {
        return currency;
    }

    /**
     * @param currency the currency to set
     */
    public void setCurrency(Boolean currency) {
        this.currency = currency;
    }

    /**
     * @return the siNumber
     */
    public String getSiNumber() {
        return siNumber;
    }

    /**
     * @param siNumber the siNumber to set
     */
    public void setSiNumber(String siNumber) {
        this.siNumber = siNumber;
    }

    /**
     * @return the total
     */
    public Double getTotal() {
        return total;
    }

    /**
     * @param total the total to set
     */
    public void setTotal(Double total) {
        this.total = total;
    }


    /**
     * @return the subtotal
     */
    public Double getSubtotal() {
        return subtotal;
    }

    /**
     * @param subtotal the subtotal to set
     */
    public void setSubtotal(Double subtotal) {
        this.subtotal = subtotal;
    }

    public DocFile getReqForInquiry() {
        return reqForInquiry;
    }

    public void setReqForInquiry(DocFile reqForInquiry) {
        this.reqForInquiry = reqForInquiry;
    }

    public Double getMemberDiscount() {
        return memberDiscount;
    }

    public void setMemberDiscount(Double memberDiscount) {
        this.memberDiscount = memberDiscount;
    }

    public Double getOrderDiscount() {
        return orderDiscount;
    }

    public void setOrderDiscount(Double orderDiscount) {
        this.orderDiscount = orderDiscount;
    }
    
}
